package com.kyzh.core.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import androidx.databinding.DataBindingUtil
import com.kyzh.core.R
import com.kyzh.core.databinding.ItemEditBinding

private var descDialog:AlertDialog?=null

fun Context.showEditDialog(title: String,   listener:String.()->Unit){
    val create = getView()

    descDialog = AlertDialog.Builder(this, R.style.kyzhGuestLoginDialog)
        .setTitle(title)
        .setView(create.root)
        .setPositiveButton("确定") { d, w ->
            create.text.text.toString().trim().listener()
            d.dismiss()
        }
        .setNegativeButton("取消") { d, w ->  d.dismiss()}
        .create()

    descDialog?.show()
}
@SuppressLint("ClickableViewAccessibility")
private fun Context.getView( )=  DataBindingUtil.inflate<ItemEditBinding>(
        LayoutInflater.from(this),
        R.layout.item_edit,null,false)
